package totiao;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

/**
 * Created by lxy_920912 on 30/03/2017.
 */
public class Main2 {
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int q = scanner.nextInt();
        int[]arr1 = new int[n];
        int[] arr2 = new int[n];
        for(int i = 0;i < n;i++){
            arr1[i] = scanner.nextInt();
        }
        for(int i = 0;i < n;i++){
            arr2[i] = scanner.nextInt();
        }
        int[] qlist = new int[q*2];
        for(int i = 0;i < qlist.length;i++){
            qlist[i] = scanner.nextInt();
        }

//        List<int[]> qlist = new ArrayList<>();
//        for(int i = 0;i < q;i++){
//            int[] qarr= new int[2];
//            for(int j = 0;j < 2;j++){
//                qarr[j] = scanner.nextInt();
//            }
//            qlist.add(qarr);
//        }
        int[] result = new int[q];
        for(int i = 0;i < q;i++){
            result[i] = 0;
        }
        for(int i = 0;i < n;i++){
            for(int j = 0;j < qlist.length;j=j+2 ){
                if(arr1[i] >= qlist[j] && arr2[i] >= qlist[j+1]){
                    result[j/2]++;
                }
            }

        }
        for(int i = 0;i < q-1;i++){
            System.out.println(result[i]+" ");
        }
        System.out.println(result[q-1]);
    }
}
